<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户博客页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog_check.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/app.js"></script>
</head>
<body>
    <div class="nav">
        <img id = "logo" src="img/logo.png" alt="">
        <span class="title">我的博客系统</span>
        <!--用于占位-->
        <span class="spacer"></span>
        <!--按钮-->
        <a href="blog_list.html"><img src="img/home.png" alt="">主页</a>
        <a href="blog_edit.html"><img src="img/edit.png" alt="">写博客</a>
        <a href="logout"><img src="img/zhuxiao.png" alt="">注销</a>
        <script src="js/jquery.min.js"></script>
        <script src="js/app.js"></script>
     </div>

     <div class="container">
        <div class="blog-list">
            
        </div>
     </div>

     <script>
        function checkBlogs() {
            $.ajax({
                type:'get',
                url:"blogscheck" + location.search,
                success:function(body) {
                    let blogList = document.querySelector(".blog-list")
                    for (let blog of body) {
                        //创建row
                        let row = document.createElement('div');
                        row.className = 'row';

                        //创建title
                        let titleDiv = document.createElement('h3');
                        titleDiv.className = "title";
                        titleDiv.innerHTML = "标题："+ blog.title;
                        row.appendChild(titleDiv);
                        //创建content
                        let contentDiv = document.createElement('div');
                        contentDiv.className = "content";
                        contentDiv.innerHTML = "摘要："+blog.content;
                        row.appendChild(contentDiv);
                        //创建a
                        let buttonA = document.createElement('a')
                        buttonA.href = "blog_detail.html"+"?blogId="+blog.blogId;
                        let button = document.createElement('button')
                        button.innerHTML='查看全文';
                        buttonA.appendChild(button);
                        row.appendChild(buttonA);
                        blogList.appendChild(row);
                    }
                }
            })
        }
        checkBlogs();
        checkLogin();
     </script>
</body>
</html>